<?php
function ListBlogByParentId($idCat,$status)
{
    global $dbsql,$language;

	$idCat         = intval($idCat);
	$sql_where     = " from tblblog where iParentId=$idCat and cLanguage='$language' ";
    if($status>-1)
    {
        $sql_where.= " and iStatus = $status ";
    }

    $sql_select    = "select count(iId) as count ".$sql_where;
	$result        = $dbsql->query_fetch($sql_select);
	$count_all	   = $result['count'];
	list($limit_st,$limit_le)=Slit_Page($count_all);
	//-----------------------------------------------------
	$sql_select = "select * ".$sql_where." order by iOrder limit $limit_st,$limit_le";
	return $dbsql->load($sql_select);
}

function ListCommentByParentId($idCat,$status)
{
    global $dbsql,$language;

	$idCat         = intval($idCat);
	$sql_where     = " from tblblog_comment where iParentId=$idCat ";
    if($status>-1)
    {
        $sql_where.= " and iStatus = $status ";
    }

    $sql_select    = "select count(iId) as count ".$sql_where;
	$result        = $dbsql->query_fetch($sql_select);
	$count_all	   = $result['count'];
	list($limit_st,$limit_le)=Slit_Page($count_all);
	//-----------------------------------------------------
	$sql_select = "select * ".$sql_where." order by iId limit $limit_st,$limit_le";
    $rs         = $dbsql->query($sql_select);
    $list       = array();
    while($result = $dbsql->fetch_array($rs))
    {
        if(intval($result['iAccountId'])>0)
        {
            $account    = getAccountById($result['iAccountId']);
            $result['cFullName']    = $account['cFullName'];
            $result['cEmail']       = $account['cEmail'];
        }
        $list[] = $result;
    }
	return $list;
}

function CountComment($idCat)
{
    global $dbsql,$language;
    $idCat          = intval($idCat);
    $sql_select     = "select count(iId) as count from tblblog_comment where iParentId=$idCat";
    $result         = $dbsql->query_fetch($sql_select);
    return $result['count'];
}
?>